package com.corpcredit.dao.impl;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.transaction.PlatformTransactionManager;

import com.business.corp.CorpForm;

public class CorpDao {
	private DataSource dataSource;

	private PlatformTransactionManager transactionManager;

	public PlatformTransactionManager getTransactionManager() {
		return transactionManager;
	}

	public void setTransactionManager(
			PlatformTransactionManager transactionManager) {
		this.transactionManager = transactionManager;
	}

	public DataSource executeTestSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	public void insertUser(final CorpForm corp) {
		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		jdbcTemplate.update("insert into qy_jbqk values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,GETDATE(),?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
				new PreparedStatementSetter() {
					public void setValues(PreparedStatement ps)
							throws SQLException {
						ps.setString( 1, corp.getQyid() );
			            ps.setString( 2, corp.getQyqc() );
			            ps.setString( 3, corp.getQywz() );
			            ps.setString( 4, corp.getZcdz() );
			            ps.setString( 5, corp.getYyzzzch() );
			            ps.setString( 6, corp.getZzjgdm() );
			            ps.setString( 7, corp.getDsdjh() );
			            ps.setString( 8, corp.getGsdjh() );
			            ps.setString( 9, corp.getDkkh() );
			            ps.setString( 10, corp.getJbhkhh() );
			            ps.setString( 11, corp.getJbhzh() );
			            ps.setString( 12, corp.getYbhkhh() );
			            ps.setString( 13, corp.getYbhzh() );
			            ps.setString( 14, corp.getJydz() );
			            ps.setString( 15, corp.getYb() );
			            ps.setString( 16, corp.getDh() );
			            ps.setString( 17, corp.getCz() );
			            ps.setString( 18, corp.getZczbbz() );
			            ps.setDouble( 19, corp.getZczbje() );
			            ps.setString( 20, corp.getClrq() );
			            ps.setString( 21, corp.getFrdb() );
			            ps.setString( 22, corp.getHyfl() );
			            ps.setString( 23, corp.getYwfw() );
			            ps.setDouble( 24, corp.getJycdmj() );
			            ps.setString( 25, corp.getFcsyq() );
			            ps.setDouble( 26, corp.getCyrs() );
			            ps.setDouble( 27, corp.getZzc() );
			            ps.setDouble( 28, corp.getXsze() );
			            ps.setString( 29, corp.getZljzrq() );
			            ps.setString( 30, corp.getQylx() );
			            ps.setString( 31, corp.getQygm() );
			            ps.setString( 32, corp.getDabh() );
			            ps.setString( 33, corp.getQycym() );
			            ps.setString( 34, corp.getKhlx() );
			            ps.setString( 35, corp.getSsqy() );
			            ps.setString( 36, corp.getOptrid() );
			            ps.setString( 37, corp.getRecstate() );
			            ps.setString( 38, corp.getRemark() );
			            ps.setInt( 39, corp.getCompanyID() );
			            ps.setShort( 40, corp.getSffr() );
			            ps.setShort( 41, corp.getSfsydw() );
			           
			            
			            
			            ps.setString( 42, corp.getEnglishname() );
			            ps.setString( 43, corp.getEmail() );
			            ps.setString( 44, corp.getZycpmc() );
			            ps.setString( 45, corp.getJyqx() );
			            ps.setString( 46, corp.getJjlx() );
			            ps.setString( 47, corp.getJglx() );
			            ps.setString( 48, corp.getJyzt() );
			            ps.setShort( 49, corp.getSfxj() );
			            ps.setString( 50, corp.getSfgxjsqy() );
			    		System.out.println(ps);
					}
				});
	}
	// public class SqlMapUserDao extends SqlMapClientDaoSupport implements
	// UserDao {
	// public boolean isItemInStock(String itemId) throws DataAccessException {
	// return true;
	// }
	//
	// public List getItemListByProduct(String productId)
	// throws DataAccessException {
	// return null;
	// }
	//
	// public User getItem(String itemId) throws DataAccessException {
	// User item = (User) getSqlMapClientTemplate().queryForObject("getItem",
	// itemId);
	// return item;
	// }

}
